<?php
/**
 * Created by PhpStorm.
 * User: allen_ios
 * Date: 17/8/12
 * Time: 下午2:55
 */

namespace Task\App\Doorbjhq;

use Task\Core\Base;
use Task\Core\RedisQueueService;

class DoneTask extends Base
{
    public function __construct()
    {
        parent::__construct();
    }

    //拉取redis中存储的同步入住任务的数据
    public function pullTaskData()
    {
        $redis = RedisQueueService::getInstance();
        $returnData = $redis->pull('bjhq_crontab');
        if(!$returnData) {
            exit("已经没有任务了！\n");
        }

        $returnData = json_decode($returnData, true);
        $className = $returnData['className'];
        $methodName = $returnData['methodName'];
        $params = $returnData['params'];
        if($params){
            $params = json_decode($params, true);
            if(is_array($params)){
                $paramStr = implode(' ', $params);
            }else{
                $paramStr = $params;
            }

            $execStr = "/usr/bin/php /mnt/lost+found/www/alpha.greencampus.cc/BEESCRM/Extend/Task/crontab.php {$className} {$methodName} {$paramStr}";
        }else{
            $execStr = "/usr/bin/php /mnt/lost+found/www/alpha.greencampus.cc/BEESCRM/Extend/Task/crontab.php {$className} {$methodName}";
        }

        $output = '';
        exec($execStr, $output);
        var_dump($output);
    }
}